package visual.Cargar;

import java.awt.BorderLayout;
import java.awt.event.*;

import javax.swing.*;

import visual.CrearPartida.Botones;
import visual.Menu.VentanaMenu;

public class VentanaCargar extends JFrame
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	Botones b;
	ScrollPanel s;
	
	public VentanaCargar()
	{
		this.setResizable(false);
		this.setAlwaysOnTop(false);
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.setSize(300, 250);
		
		b = new Botones("Aceptar", "Cancelar");
		s = new ScrollPanel();
		
		JPanel p2 = new JPanel();
		p2.setLayout(new BorderLayout());
		p2.add(s, "Center");
		
		JPanel p = new JPanel();
		p.setLayout(new BorderLayout());
		p.add(p2, "Center");
		p.add(b, "South");
		
		this.add(p);
		
		MouseListener mouseListener = new MouseAdapter() 
		{
		    public void mouseClicked(MouseEvent e) 
		    {
		    	b.b1.setEnabled(true);
		    }
		};
		
		b.b1.setEnabled(false);
		
		s.lista.addMouseListener(mouseListener);
		b.b2.addActionListener(new escuchador());
		

		DefaultListModel modelo = new DefaultListModel();
		s.lista.setModel(modelo);
	}
	
	public static void main (String[] args)
	{
		VentanaCargar v = new VentanaCargar();
		v.setVisible(true);
	}
	
	class escuchador implements ActionListener
	{

		@Override
		public void actionPerformed(ActionEvent e)
		{
			if(e.getActionCommand() == "Cancelar")
			{
				dispose();
				VentanaMenu v = new VentanaMenu();
				v.setVisible(true);
			}
		}
		
	}
}
